﻿using Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hotfix
{
    [ObjectEvent]
    public class HttpDataComponentEvent : ObjectEvent<HttpDataComponent>, IAwake,IAwake<PlayType>,IStart
    {
        public void Awake()
        {

        }

        public void Awake(PlayType p1)
        {
            this.Get().Awake(p1);
        }

        public void Start()
        {
            this.Get().Start();
        }
    }

    public static  class HttpDataComponentSystem
    {
        public static void Awake(this HttpDataComponent self,PlayType type)
        {
            switch (type)
            {
                case PlayType.KL8:
                    AwakeKL8(self);
                    break;
                default:
                    break;
            }
        }

        public static void AwakeKL8(HttpDataComponent self)
        {
            DateTime now = DateTime.Now;
            DateTime startTime = new DateTime(now.Year, now.Month, now.Day, 9, 5, 20);
            DateTime endTime = new DateTime(now.Year, now.Month, now.Day, 23, 55, 20);

            // 生成时间，每隔5分钟。
            Queue<DateTime> queue = TimeHelper.GeneratorTimes(startTime, endTime, 1000 * 60 * 5);

            self.DataParser = new Parser();
            self.uri = "http://www.bwlc.net/";
            self.Awake(PlayType.KL8, queue);
        }
    }
}
